package com.qf.blog.email.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public DirectExchange messageExchange() {
        return new DirectExchange("message-exchange");
    }

    @Bean
    public Queue emailQueue() {
        return new Queue("email-queue", true, false, false);
    }

    @Bean
    public Queue emsQueue() {
        return new Queue("ems-queue", true, false, false);
    }

    @Bean
    public Binding emailQueueBindMessageExchange() {
        return BindingBuilder.bind(emailQueue()).to(messageExchange()).with("email");
    }

    @Bean
    public Binding emsQueueBindMessageExchange() {
        return BindingBuilder.bind(emsQueue()).to(messageExchange()).with("ems");
    }
}
